package com.sanfu.etl.pojo;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Repository;

import java.io.IOException;

// *********************
// ** @Date: 2021-06-29
// ** @Author: Camemax
// ** @Description: HBase配置实体类
// *********************
@Repository
@ConfigurationProperties( prefix = "hbase.zookeeper")
public class HBaseInfo {
    // 指定HBase服务地址
    @Value("${hbase.zookeeper.quorum}")
    private String quorum ;

    public Connection hbaseConnection(){
        Connection conn = null;
        try {
            // 加载配置
            Configuration conf = HBaseConfiguration.create();
            conf.set("hbase.zookeeper.quorum",quorum);
            conn = ConnectionFactory.createConnection(conf);
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 返回链接
        return conn;
    }
}
